<script type="text/javascript">
function profile(){
	var url= root+'users/profile';
	$.post(
		url,
		$('#fr_register').serialize(),
		function(data){
			if(data.st=='SUCCESS'){
				$('.p_notification').css({'color':'#038C3C'}).html('Lưu thông tin thành công');
				setTimeout("hide_popup()",1000);
			}else{
				$.each(data.error,function(index,obj) {
					$('.p_notification').css({'color':'#EE1C25'}).html(obj.txt);
					return false;
				});
			}
		},"json"
	);
}

function profile_s1(){
	var password= $('#password').val();
	var re_password= $('#re_password').val();
	if(password!=''||password.length>=6){
		if(password.length<6){
			$('.p1_notification').html('Mật khẩu ngắn hơn 6 ký tự.');
			return false;
		}else{
			if(re_password==''){
				$('.p1_notification').html('Bạn chưa nhập lặp lại mật khẩu.');
				return false;
			}else{
				if(password!=re_password){
					$('.p1_notification').html('Hai mật khẩu không trùng khớp.');
					return false;
				}
			}
		}
	}
	$('.p1_notification').html('');$('.w_step').hide();$('.step_2').show();
}

function profile_s2(){
	var fullname= $('#fullname').val();
	var phone= $('#cmnd').val();
	var address= $('#address').val();
	if(fullname==''){
		$('.p2_notification').html('Bạn chưa nhập họ & tên');
		return false;		
	}
		
	if(phone!='')
	{
		if(isNaN(phone)){
			$('.p2_notification').html('Số điện thoại không hợp lệ')
			return false;
		}else if(phone.length<9){
			$('.p2_notification').html('Số điện thoại không hợp lệ')
			return false;
		}
	}
	else
	{
		$('.p2_notification').html('Bạn chưa nhập số điện thoại')
		return false;			
	}
	
	if(address==''){
		$('.p2_notification').html('Bạn chưa nhập địa chỉ');
		return false;		
	}
	$('.p2_notification').html('');$('.w_step').hide();$('.step_3').show();
}


function back_s1(){
	$('.w_step').hide();$('.step_1').show();
}
function back_s2(){
	$('.w_step').hide();$('.step_2').show();
}

function check_form(element){
	var url= root+'users/check_form';
	var val= $(element).val();
	var param= element.substr(1, element.length);
	//console.debug(param);
	var post_data = {};
	post_data[param] = val;post_data['ac'] = param;
	if(val!='')
	{
		$.post(
			url,
			post_data,
			function(data){
				$.map(data.error, function(item){
					//alert(item.txt);
					console.debug(item.txt);
				});
			},"json"
		);
	}
	else
	{
		alert('*');
	}
}
</script>
<div class="popup_profile png">
<form action="" id="fr_register" method="post" enctype="multipart/form-data">
	<a href="javascript:void(0)" title="Đóng" class="close_popup" onclick="return hide_popup();"></a>
	<div class="p_content_popup">
		<div class="popup_tt"><img src="<?=PATH_URL?>static/images/iphone/popup/text/tai_khoan_thanh_vien.png" alt="" align="center" /></div>
		<div class="popup_ct">
			<div class="step_1 w_step">
				<div class="username">
					<span style="float:left;">TÊN ĐĂNG NHẬP</span>
					<span style="margin-left:8px;float:left;">
						<span class="span_input_l"><?=$USER->username?></span>
						<div class="clearAll"></div>
					</span>	
					<div class="clearAll"></div>
				</div>
				<div class="password" style="padding:20px 0 0 51px;">
					<span>MẬT KHẨU</span>
					<span style="margin-left:8px;"><input type="password" name="password" id="password" class="input_l" value="" /></span>						
				</div>	
				
				<div class="re_password" style="padding:20px 0 0 45px;">
					<span>LẶP LẠI MK</span>
					<span style="margin-left:8px;"><input type="password" name="re_password" id="re_password" class="input_l" value="" /></span>	
				</div>
				<div class="p1_notification"></div>
				<div class="button">
					<span onclick="return profile_s1();"><img src="<?=PATH_URL?>static/images/iphone/popup/button/tiep_theo.png" alt="" /></span>
				</div>
			</div>
			
			<div class="step_2 w_step" style="display:none;">
				<div class="fullname" style="padding:18px 0 0 27px;">
					<span>HỌ & TÊN</span>
					<span style="margin-left:8px;"><input type="text" name="fullname" id="fullname" class="input_l" value="<?=$USER->fullname?>" /></span>				
				</div>
				
				<div class="phone" style="padding:28px 0 0 11px;">
					<span>ĐIỆN THOẠI</span>
					<span style="margin-left:8px;"><input type="text" name="phone" id="phone" class="input_l" value="<?=$USER->phone?>"  /></span>		
				</div>
				
				<div class="address" style="padding:29px 0 0 39px;">
					<span>ĐỊA CHỈ</span>
					<span style="margin-left:8px;"><input type="text" name="address" id="address" class="input_l" value="<?=$USER->address?>"  /></span>				
				</div>	
				<div class="p2_notification"></div>
				<div class="button">
					<span onclick="return back_s1();"><img src="<?=PATH_URL?>static/images/iphone/popup/button/quay_lai.png" alt="" /></span>
					<span onclick="return profile_s2();"><img src="<?=PATH_URL?>static/images/iphone/popup/button/tiep_theo.png" alt="" /></span>
				</div>
			</div>
			
			<div class="step_3 w_step" style="display:none;">
				<div class="cmnd" style="padding:27px 0 0 80px;">
					<span>SỐ CMND</span>
					<span style="margin-left:8px;"><input type="text" name="cmnd" id="cmnd" class="input_l" value="<?=$USER->cmnd?>"/></span>						
				</div>
			
				<div class="email" style="padding:27px 0 0 120px;">
					<span style="float:left;">EMAIL</span>
					<span style="margin-left:8px;float:left;">
						<span class="span_input_l"><?=$USER->email?></span>
						<div class="clearAll"></div>
					</span>	
					<div class="clearAll"></div>			
				</div>
				
				<div class="code" style="padding:20px 0 0 67px;color:#ee1c25;">
					<span style="float:left;">MÃ VẠCH SẢN PHẨM</span>
					<span style="margin-left:8px;float:left;">
						<span class="span_input_code"><?=$USER->code?></span>
						<div class="clearAll"></div>
					</span>	
					<div class="clearAll"></div>
				</div>

				<input type="hidden" name="device" id="device" value="true" class="input_code" />
				<div class="p_notification"></div>
				<div class="button">
					<span onclick="return back_s2();"><img src="<?=PATH_URL?>static/images/iphone/popup/button/quay_lai.png" alt="" /></span>
					<span onclick="return profile();"><img src="<?=PATH_URL?>static/images/iphone/popup/button/luu_thong_tin.png" alt="" /></span>

				</div>				
			</div>
		</div>
	</div>
</form>
</div>